package com.jing.weibo.service.user;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.jing.system.model.PageCls;
import com.jing.weibo.mapper.user.UserPointLogMapper;
import com.jing.weibo.pojo.user.UserPointLog;

/**
 * 用户积分的Service
 * @author jing.yue
 * @version 2012/09/29 1.0.0
 */
@Component
public class UserPointLogService {

	@Autowired
	private UserPointLogMapper userPointLogMapper;

	/**
	 * 保存用户积分信息
	 * @param userPointLog
	 * @throws Exception
	 */
	public void saveUserPointLog(UserPointLog userPointLog) throws Exception {
		userPointLogMapper.saveUserPointLog(userPointLog);
	}

	/**
	 * 根据用户名获取用户积分记录信息
	 * @param userPointLog
	 * @return
	 * @throws Exception
	 */
	public Map<String, Object> findByUsernamePoint(UserPointLog userPointLog) throws Exception {
		List<UserPointLog> userPointLogs = userPointLogMapper.findByUsernamePoint(userPointLog);
		Integer countSize = userPointLogMapper.findByUsernamePointCount(userPointLog);
		PageCls pageCls = PageCls.setPageCls(userPointLog.getPage(), userPointLog.getSize(), null, null, countSize, userPointLogs.size(), userPointLogs);
		return pageCls.getPageInfo();
	}

}